package org.yangspring.samples.mvc.simple;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yangspring.samples.mvc.domain.WhyangBank;
import org.yangspring.samples.mvc.service.WhyangbankService;

import java.util.List;

import static java.lang.System.out;

/**
 * Created by whyang on 2017/06/20.
 */

@Controller
@RequestMapping("/bank")
public class BankController {
    private static final Logger logger = LoggerFactory.getLogger(BankController.class);

    @Autowired
//    @Resource(name = "bankService")
    private WhyangbankService bankService;

    @RequestMapping(value = "/list")
    public String listAccount(Model model){

        model.addAttribute("bank001", new WhyangBank());
        List<WhyangBank> bankkks = this.bankService.listAccount();
        logger.warn("\n\nbankkks Quantity:\t" + bankkks.size() + "\n\n");
        model.addAttribute("listBank003", bankkks);
        return "listBank";
    }

    @RequestMapping(value = "/list0")
    public String listAccount0(Model model){
        List<WhyangBank> bankkks = this.bankService.listAccount();
        logger.warn("\n\nbankkks Quantity:\t" + bankkks.size() + "\n\n");
        model.addAttribute("listBank003", bankkks);
        return "listBank";
    }

}
